//
//  LYCertificateListCell.m
//  Btpin
//
//  Created by liuyan on 2019/4/18.
//  Copyright © 2019年 Vic. All rights reserved.
//

#import "LYCertificateListCell.h"

@interface LYCertificateListCell()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation LYCertificateListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubViews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - InitSubViews
- (void)initSubViews{
    UIImageView *nextImage = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH -20, 17 , 8,16)];
    nextImage.image = [UIImage imageNamed:@"jiantou_right"];
    [self.contentView addSubview:nextImage];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(nextImage.left - 70, 0, 70, 50)];
    self.detailLabel.font = [UIFont systemFontOfSize:13];
    self.detailLabel.textColor = RGB(34, 34, 34);
    [self.contentView addSubview:self.detailLabel];

    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, self.detailLabel.left - 18, 50)];
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.textColor = RGB(34, 34, 34);
    [self.contentView addSubview:self.titleLabel];
}

-(void)setEducatModel:(PMineResumeEducationInfoModel *)educatModel{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:educatModel.school];
    NSAttributedString *strq = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"  %@",educatModel.education_cn] attributes:@{NSForegroundColorAttributeName :RGB(85, 85, 85),NSFontAttributeName : [UIFont systemFontOfSize:12]}];
    [str appendAttributedString:strq];
    self.titleLabel.attributedText = str;
    
//    NSArray *array = educatModel.imgs;
//    NSInteger count = 0;
//    for (NSDictionary *dic in array) {
//        NSInteger audit = [dic[@"audit"] integerValue];
//        if (audit == 1) {
//            count ++;
//        }
//    }
    
    NSInteger count = 0;
    for (ImageModel *tempModel in educatModel.imagesArray) {
        if ([tempModel.audit isEqualToString:@"1"]) {
            count ++;
        }
    }
    
    if (count >0) { //已认证
        self.detailLabel.text = @"已认证";
        self.detailLabel.textColor = [UIColor orangeColor];
    } else { //未认证
        self.detailLabel.text = @"未认证";
        self.detailLabel.textColor = RGB(153, 153, 153);
    }
}

-(void)setWorkModel:(PMineResumeWorkInfoModel *)workModel{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:workModel.company_name];
    NSAttributedString *strq = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"  %@",workModel.job_name] attributes:@{NSForegroundColorAttributeName :RGB(85, 85, 85),NSFontAttributeName : [UIFont systemFontOfSize:12]}];
    [str appendAttributedString:strq];
    self.titleLabel.attributedText = str;
    
    NSArray *array = workModel.images;
    NSInteger count = 0;
    for (ImageModel *tempModel in array) {
        NSInteger audit = [tempModel.audit integerValue];
        if (audit == 1) {
            count ++;
        }
    }
    
    if (count >0) {
        //已认证
        self.detailLabel.text = @"已认证";
        self.detailLabel.textColor = [UIColor orangeColor];
    }else{
        //未认证
        self.detailLabel.text = @"未认证";
        self.detailLabel.textColor = RGB(153, 153, 153);
    }
}

@end
